#ifndef __EXCEPTIONS_H__
#define __EXCEPTIONS_H__

#include <stdexcept>

#define BOSS_DECLARE_EXCEPTION_EX(prefix_class_name, base_class) \
  class prefix_class_name##Exception \
    : public base_class \
  { \
  public: \
    prefix_class_name##Exception(const std::string &msg, unsigned long code = 0) \
      : base_class(msg) \
      , Code(code) \
    { \
    } \
    virtual unsigned long GetCode() const \
    { \
      return Code; \
    } \
  private: \
    unsigned long Code; \
  };

#define BOSS_DECLARE_RUNTIME_EXCEPTION(prefix_class_name) \
  BOSS_DECLARE_EXCEPTION_EX(prefix_class_name, std::runtime_error)

#define BOSS_DECLARE_LOGIC_EXCEPTION(prefix_class_name) \
  BOSS_DECLARE_EXCEPTION_EX(prefix_class_name, std::logic_error)

#endif  // !__EXCEPTIONS_H__
